/**
 *@ autores : Saulo de tarso Oliveira da Silva
 *  29/03/2011
 */
package model;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Usuario implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long idUsuario;
    @Column(nullable = false, length = 50)
    private String nome;
    @Column(nullable = false, length = 30)
    private String email;
    @Column(unique = true, nullable = false, length = 20)
    private String login;
    /**
     * O campo senha tem um tamanho de 128 caracteres pois a senha gerada pela encripta��o
     * SHA-512 gera uma sa�da deste tamanho.
     */
    @Column(unique = false, nullable = false, length = 128)
    private String senha;
    @Column(unique = false, nullable = true, length = 128)
    private String senhaAuxiliar;
    @Column(unique = true, nullable = true, length = 20)
    private String url;
    @OneToMany(fetch = FetchType.LAZY)
    @JoinColumn(name = "idIndicacoes")
    @Cascade(CascadeType.ALL)
    private List<Usuario> indicacoes = new LinkedList<Usuario>();
    @OneToMany(fetch = FetchType.LAZY)
    @JoinColumn(name = "idUsuario")
    @Cascade(CascadeType.ALL)
    private List<Cupom> cupons = new LinkedList<Cupom>();
    @OneToOne(mappedBy = "usuario")
    @Cascade(CascadeType.ALL)
    private Pesquisa pesquisa;

    public Usuario() {
    }

    public List<Usuario> getIndicacoes() {
        return indicacoes;
    }

    public void setIndicacoes(List<Usuario> indicacoes) {
        this.indicacoes = indicacoes;
    }

    public List<Cupom> getCupons() {
        return cupons;
    }

    public void setCuponsA(List<Cupom> cupons) {
        this.cupons = cupons;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public long getIdUsuario() {
        return idUsuario;
    }

    public void setIdUsuario(long idUsuario) {
        this.idUsuario = idUsuario;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public Pesquisa getPesquisa() {
        return pesquisa;
    }

    public void setPesquisa(Pesquisa pesquisa) {
        this.pesquisa = pesquisa;
    }

    public String getSenha() {
        return senha;
    }

    public void setSenha(String senha) {
        this.senha = senha;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getSenhaAuxiliar() {
        return senhaAuxiliar;
    }

    public void setSenhaAuxiliar(String senhaAuxiliar) {
        this.senhaAuxiliar = senhaAuxiliar;
    }
}
